limsQualityControlChart.chartEditPage = {

    getNorthFormParam : function(){
        let _this = this;
        let date = new Date();
        let endDate = Gikam.DateUtils.formatter(date, 'yyyy-MM-dd hh:mm:ss');
        let startDate = Gikam.DateUtils.formatter(new Date(date.setDate(date.getDate()-7)), 'yyyy-MM-dd hh:mm:ss');
        return {
            type : 'form',
            id : 'search-info-form',
            columns : 2,
            fields : [{
                field : 'startTime',
                title : 'T_EQUIP_MAINTAIN_RECORD.STARTTIME',
                validators : ['notEmpty'],
                inputWidth : 150,
                type : 'dateTime',
                value : startDate
            },{
                field : 'endTime',
                title : 'T_FILEAPPLICATION.ENDTIME',
                validators : ['notEmpty'],
                inputWidth: 150,
                type : 'dateTime',
                value : endDate
            },{
                field : 'group',
                title : 'T_LIMS_PRODUCTGROUP.PROFESSIONALGROUP',
                colspan : 2,
                type : 'comboBox',
                inputWidth: 200,
                validators : ['notEmpty'],
                firstBlank : false
            },{
                field : 'equip',
                title : 'T_LIMS_PRODUCT_EQUIPMENT.EQUIPMENTNAME',
                colspan: 2,
                type : 'comboBox',
                inputWidth: 200,
                firstBlank: false,
                validators : ['notEmpty']
            },{
                field : 'qualityChart',
                title : 'T_QUALITY_CONTROL.CHART',
                type : 'select',
                //validators : ['notEmpty'],
                category : 'sys',
                param : {
                    codeCategoryId : 'qualityChart'
                },
                firstBlank: false
            }],
            onLoadSuccess : function (data) {
                let form = getComp('search-info-form');
                Gikam.getJson(limsQualityControlChart.baseUrl + '/selectable/group'+Gikam.param({
                    startTime : data.startTime,
                    endTime : data.endTime
                })).done(function (data) {
                    let items = [];
                    data.forEach(function (item) {
                        items.push({
                            text : item.professionGroup,
                            value : item.professionGroup
                        })
                    });
                    form.setSelectOptions('group', items);
                })
                if (!form.validate()){
                    return;
                }
            }
        }
    },

    getCenterTabParam : function(){
        let _this = this;
        return {
            type : 'tab',
            id : 'left-center-tab',
            panels: [{
                title: 'QUALITY.CONTROL.LEVEL.TAB.TITLE',
                id: 'quality-level-tab',
                items: [_this.getQualityLevelParam()]
            }, {
                title: 'QUALITY.CONTROL.PRODUCT.TAB.TITLE',
                id: 'quality-product-tab',
                items: [_this.getQualityProductParam()]
            }]
        }
    },

    getQualityLevelParam : function(){
        return {
            type : 'grid',
            id : 'quality-level-list-grid',
            page : true,
            url : limsQualityControlChart.baseUrl + '/queries',
            group : {
                groupCheckbox: true,
                fields: ['productCode'],
                formatter: function (row) {
                    return Gikam.propI18N("T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALLEVEL") + '：' + row.controlMaterialLevel + ' —— ' +
                        Gikam.propI18N("T_LIMS_QUALITYCONTROL_TEST_RESULT.PRODUCTNAME") + '：' + row.productName+
                        ' —— ' + Gikam.propI18N("T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALNAME") + '：' + row.controlMaterialName;
                },
                expand: true
            },
            columns : limsQualityControlChart.getQualityColumns()
        }
    },

    getQualityProductParam : function(){
        return {
            type : 'grid',
            id : 'quality-product-list-grid',
            page : true,
            url : limsQualityControlChart.baseUrl + '/queries',
            group : {
                groupCheckbox: true,
                fields: ['controlMaterialLevel'],
                formatter: function (row) {
                    return Gikam.propI18N("T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALLEVEL") + '：' + row.controlMaterialLevel + ' —— ' +
                        Gikam.propI18N("T_LIMS_QUALITYCONTROL_TEST_RESULT.PRODUCTNAME") + '：' + row.productName+
                        ' —— ' + Gikam.propI18N("T_LIMS_QUALITYCONTROL_TEST_RESULT.CONTROLMATERIALNAME") + '：' + row.controlMaterialName;
                },
                expand: true
            },
            columns : limsQualityControlChart.getQualityColumns()
        }
    },

    getTabParam : function(){
        let _this = this;
        return {
            type : 'layout',
            north : {
                height : '400',
                items : [_this.getNorthFormParam()]
            },
            center : {
                items : [_this.getCenterTabParam()]
            }
        }
    },

    create : function(){
        let _this = this;
        Gikam.create('layout',{
            id : 'lims-quality-control-chart-edit-list-layout',
            renderTo : workspace.window.$dom,
            west : {
                width : '100%',
                items : [_this.getTabParam()]
            },
            /*center : {
                items : []
            },
            east : {
                width : '20%',
                items : []
            }*/
        })
    },

    init : function (param) {
        this.param = param;
        this.param.tabIndex = 0;
        this.create();
    }
}